package com.example.demo.verify;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.regex.Pattern;

public class NoNumValidator implements ConstraintValidator<NoNum, Object> {
    @Override
    public boolean isValid(Object obj, ConstraintValidatorContext context) {
        if (obj == null || obj.toString().trim().isEmpty()) {
            return false;
        }

        String reg = "^[1-9]\\d*|0$";
        return Pattern.matches(reg, obj.toString());
    }
}
